package cn.tannn.ops.sys.controller.dto;

import cn.tannn.ops.sys.domain.SysConfigEnum;
import cn.tannn.ops.sys.domain.WorkerConfig;
import cn.tannn.ops.sys.entity.SysConfig;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * 编辑定时任务里的一些通用配置
 *
 * @author tnnn
 * @version V1.0
 * @date 2024-10-9
 */
@Schema(description = "编辑定时任务里的一些通用配置")
@ToString
@Getter
@Setter
public class WorkerConfigEdit {

    /**
     * 域名证书过期通知时间设置/天
     */
    @Schema(description = "域名证书过期通知时间设置/天",defaultValue = "10",requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull
    Integer domainSslExpiryDay;


    public SysConfig toSysConfig() {
        SysConfig config = new SysConfig();
        config.setCode(SysConfigEnum.WORKER_CONFIG.getCode());
        config.setTitle(SysConfigEnum.WORKER_CONFIG.getTitle());
        WorkerConfig worker = new WorkerConfig();
        worker.setDomainSslExpiryDay(domainSslExpiryDay);
        config.setData(worker.toJson());
        return config;
    }

}
